<?php

class Autocomplit extends Controller {

	function Autocomplit() {
		parent::Controller();	
        
        
	}
	
 
    
	function index() {
        if (!$this->session->userdata('username')) {
            redirect('login');        
        }  
        
	}
 
    
     
     function namauser() {
        $q = strtolower($_POST["q"]);
        if (!$q) return;

        $nm = $this->db->get('user');
        foreach($nm->result() as $row)
        {
            
            $items[$row->namauser] = $row->nama_asli;
            
        }

        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
             
            
            }
        }
           
    //nama pegawai
    function emailuser() {
        $q = strtolower($_POST["q"]);
        if (!$q) return;
        
        $nm = $this->db->get('user');
        foreach($nm->result() as $row)
        {
            
            $items[$row->namauser] = $row->email;
            
        }

        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
            
            }
        }
        
    //bentuk hukuman
    function bentuk_hukuman($id) {
        $q = strtolower($_POST["q"]);
        if (!$q) return;
        
        
        $this->db->where("id_jenis_hukuman = $id");
        
        $nm = $this->db->get('bentuk_hukuman');
        foreach($nm->result() as $row)
        {
            
            $items[$row->nama] = $row->idpta_bentuk_hukuman;
            
        }
         
        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
            
            }
            
        }
        
        //pejabat
        function pejabat() {
        $q = strtolower($_POST["q"]);
        if (!$q) return;
        
        $nm = $this->db->get('pejabat');
        foreach($nm->result() as $row)
        {
            
            $items[$row->nama] = $row->idpta_pejabat;
            
        }
         
        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
            
            }
            
        }
        
        //jurusan
        function jurusan() {
        $q = strtolower($_POST["q"]);
        if (!$q) return;
        
        $nm = $this->db->get('jurusan');
        foreach($nm->result() as $row)
        {
            
            $items[$row->nama] = $row->idpta_jurusan;
            
        }
         
        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
            
            }
            
        }
    
    //pangkat
        function pangkat() {
        $q = strtolower($_POST["q"]);
        if (!$q) return;
        
        $nm = $this->db->get('pangkat');
        foreach($nm->result() as $row)
        {
            
            $items[$row->nama] = $row->idpta_pangkat;
            
        }
         
        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
            
            }
            
        }
        
       //jabatan 
        function jabatan($kode) {
        $q = strtolower($_POST["q"]);
        if (!$q) return;
        $this->db->where(array('tipe' => $kode));     
        $nm = $this->db->get('jabatan');
        foreach($nm->result() as $row)
        {
            
            $items[$row->nama] = $row->idpta_jabatan;
            
        }
         
        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
                }
            
            }
            
        }
 
}

/* End of file main_admin.php */
/* Location: ./system/application/controllers/main_admin.php */